The present invention relates to compression algorithms in a computer graphics system, and more particularly to compressing data to be stored in a frame buffer of a computer graphics system.
Rendering a computer-generated image entails several steps. Such an image is traditionally composed of many primitive objects, e.g. triangles. Each triangle is initially transformed into a screen-aligned coordinate system. Thereafter, rasterization breaks each triangle into fragments. Conventionally, there is one fragment for each screen pixel covered by the triangle.
Each fragment has associated with it a number of data items, including one or more color and depth values. The depth value is used to determine which fragments will be visible on the screen (z-buffering). The fragment color and depth values are written to the display memory if the fragment is determined to be visible.
A typical scene is composed of many triangles. As each triangle covers a number of pixels, the number fragments to be written to the display memory can be large. For instance, a scene may be composed of 1,000,000 triangles, each of which may cover 50 pixels. If the scene is rendered 60 times a second, 300,000,000 fragments must be generated, processed and sent to the frame buffer every second.
If each such fragment carries about 10 bytes of data, 3 Gbytes of data must be processed and stored every second. Further, many applications arithmetically blend newly rendered fragments with the contents of the frame buffer, doubling the data that must be transferred to and from the frame buffer.
The foregoing problem is exacerbated if anti-aliasing is performed. In the most common antialiasing algorithms, supersampling, and multisampling; multiple fragments are computed and stored in the frame buffer for every screen pixel in order to reduce sampling artifacts in the rendered image (See U.S. Pat. No. 6,072,500). Antialiasing using these techniques, therefore, increases the load imposed on the fragment processing stage of a graphics system proportionally to the number of samples per pixel.
In particular, the problems associated with processing a large number of fragments are set forth Table 1.
There is thus a need for a graphics processing technique that addresses these problems by compressing fragments as they travel through the graphics system and by storing them in a compressed format in the frame buffer.
A system and method are provided for the compression of pixel data for storing the same in a frame buffer during the process of rendering. Initially, a plurality of samples is received. It is then determined whether the samples are capable of being compressed. The samples are then compressed if it is determined that the samples are capable of being compressed. The samples are then transferred to a frame buffer for storage therein.
In one embodiment, the samples may be packed into tiles corresponding to rectangular regions in screen space. Further, some of the samples in the rectangular regions may be null. As an option, the samples may be generated by multi-sampling. Such multi-sampling may produce identical color values for samples covered by a primitive. Still yet, the compression may be lossless.
In another embodiment, the aforementioned determining operation may include determining whether all of the samples are covered. Further, the determining operation may include determining whether all of the samples that fall within the same pixel have identical color values. Such operations may thus represent pre-conditions for compression.
In still another embodiment, the compression may represent samples of identical color value by one sample with the color value, i.e. reduction. Moreover, the compression may include reduction and compaction. While reduction represents samples of identical color value by one sample with the color value, compaction reduces the number bits required to store the samples. Compaction may be performed by any of a variety of methods for compressing regions of image data, such as vector quantization, wavelet compression, color cell coding, or other methods that will be readily apparent to one skilled in the art.
In still another embodiment, compaction may include: establishing an anchor sample, computing gradients in two independent directions, computing predicted pixel values for all samples, computing differences between predicted and actual sample values, determining whether the gradients and the differences are capable of being represented with a predetermined number of bits, and storing the anchor sample, the gradients and the differences with the predetermined number of bits, if possible. As an option, the compaction may be performed by a selected one of several methods, where the selected method is encoded in the compressed samples.
In still another embodiment, the aforementioned transferring operation may include storing compressed samples if it is determined that the samples are capable of being compressed and storing uncompressed samples if it is determined that the samples are incapable of being compressed. One or more bits may be stored in memory to indicate whether the samples are stored compressed or uncompressed, and, as an option, to select among compression formats. Such memory may reside on a chip capable of processing the samples.
Another system and method are provided for processing compressed pixel data. Initially, a plurality of samples is received. Optionally, for example, if needed for blending, or to expand compressed data, samples are read from a frame buffer. The data is read from a location in the frame buffer associated with the received samples. Data that is read may be returned compressed or uncompressed.
It is then determined whether the samples can be processed in reduced form or if they must be processed in expanded (non-reduced) form. These samples are then processed in the appropriate form. Then, an attempt is made to compress the processed samples, and the processed samples are written to the frame buffer.
In one aspect of the present embodiment, the plurality of samples may be generated by multi-sampling. Further, the plurality of samples may be organized as rectangular regions in screen space.
In another aspect, the reading may include identifying samples that are covered, issuing a read request to the frame buffer for the covered samples, receiving color values for the covered samples, and un-compacting the color values if the read color samples are stored compressed in the frame buffer and need to be compacted.
As an option, the read request may include a conditional read request. A conditional read request returns data only if the samples stored in the frame buffer are compressed. Conditional read requests may be useful to efficiently expand compressed samples when new samples are received that cannot be compressed and frame buffer samples are not otherwise needed, for example, for blending.
In still another aspect, the determining operation may include determining whether the samples are in reduced form. Moreover, the processing may include using a color value that represents all of the samples in reduced form.
On the other hand, the processing in expanded form may include expanding reduced received samples into expanded form. It may also include expanding read samples into expanded form. Thereafter, the samples are processed in the expanded form.
In still yet another aspect, the aforementioned attempting operation may include (i) determining whether all of the received samples are covered, determining whether all of the received samples are in reduced form, (ii) determining whether it is permissible to store the received samples in a compressed form, and (iii) determining whether the received samples are capable of being represented in the compressed form. As such, the received samples may be converted to the compressed form if (i)-(iii) are true.
Another system and method are provided for transferring a set of samples to a frame buffer in a graphics system. Initially, a set of a plurality of samples is received. It is then determined whether the set of samples is capable of being compressed. If it is determined that the set of samples is capable of being compressed, the set of samples is compressed. Then, the set of samples is transferred to a frame buffer. A size of the set of samples is dictated by a transaction size of the frame buffer.
In one aspect of the present embodiment, a set of samples may be transferred from the frame buffer, and optionally compressed. Moreover, the set of samples may include a rectilinear set of samples. Still yet, the transaction size of the frame buffer may be a size of data that the frame buffer is capable of reading and writing. As an option, a plurality of the sets of samples may form a single frame.
As an option, the compressed samples read during scan out processing of one scan line may be retained and used for processing of subsequent scan lines.
In another embodiment, the frame buffer may be cleared by writing compressed samples to the frame buffer. Further, an identifier may be included in the compressed samples indicating that the compressed samples are associated with the clearing of the frame buffer.
Still yet, the various operations above may be carried out xe2x80x9con-the-fly,xe2x80x9d or in other words, during a frame buffer read or write update process.
These and other advantages of the present invention will become apparent upon reading the following detailed description and studying the various figures of the drawings.